/*
Java source file
Copyright: Umschalt.com 2012
*/
package com.david.documentation.web.view.pages;

import com.david.documentation.web.BasePage;
import org.apache.wicket.behavior.SimpleAttributeModifier;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.HiddenField;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;

import java.io.IOException;

public class TestPage extends BasePage{


	public TestPage(){

		Document document = null;
		String html = "";

		String imageSrc = "";
		String hiddenField = "";


		try {
			document = Jsoup.connect("http://download.serienjunkies.org/f-c331dcfab15c98cd/fc_2012-mayaprophezeiung.html").ignoreContentType(true).get();
			org.jsoup.select.Elements elements = document.select("body center");
			String src = elements.select("img").get(0).attr("src");
			imageSrc = "http://download.serienjunkies.org" + src;

			hiddenField = elements.select("input[type=HIDDEN]").get(0).val();
			elements.select("img").get(0).attr("src",imageSrc);

			html = elements.html();

		} catch (IOException e) {
			e.printStackTrace();
		}

		WebMarkupContainer image = new WebMarkupContainer("image");
		image.add(new SimpleAttributeModifier("src",imageSrc));
		add(image);

		HiddenField hidden = new HiddenField("hidden");
		hidden.add(new SimpleAttributeModifier("value",hiddenField));
		hidden.add(new SimpleAttributeModifier("name","s"));
		add(hidden);

		Label container = new Label("container", html);
		container.setEscapeModelStrings(false);
		add(container);

	}

}
